{include file="public/header" title="密码修改"/}
<!-- start page -->
<div class="container bs-docs-container">
    <div class="row">
        <!-- 左侧导航栏 start -->
        {include file="Public/sidebar"/}
        <!-- 左侧导航栏 end -->
        <div class="col-lg-10 col-md-10 col-sm-8">
            <div class="page-header">
                <h2 class="titleh">密码修改</h2>
            </div>
            <div class="content">
                <div class="col-lg-4 col-sm-4 col-md-4">
                    <div class="panel panel-success">
                        <div class="panel-heading">学号</div>
                        <div class="panel-body">
                            <p>{$info.std_id}</p>
                            <input type="hidden" value="{$info.std_id}" id="std_id_hidden">
                        </div>
                    </div>
                </div>
                <div class="col-lg-4 col-sm-4 col-md-4">
                    <div class="panel panel-info">
                        <div class="panel-heading">原始密码</div>
                        <div class="panel-body">
                            <input type="text" class="form-control" id="old_password">
                        </div>
                    </div>
                </div>
                <div class="col-lg-4 col-sm-4 col-md-4">
                    <div class="panel panel-success">
                        <div class="panel-heading">新密码</div>
                        <div class="panel-body">
                                <input type="text" class="form-control" id="new_password">
                        </div>
                    </div>
                </div>
                <div class="col-lg-2 col-sm-2 col-md-2">
                    <button type="button" class="btn btn-primary" id="sumbit_info">保存</button>
                </div>
                <div class="col-lg-4 col-sm-4 col-md-4">
                    <p id="sumbit_warning"></p>
                </div>
                <!-- end statistics -->
            </div>
        </div>
    </div>
</div>
<script>
    $("#student_set").addClass("active");
    $("#sumbit_info").click(function () {
        var std_id=$("#std_id_hidden").val();
        var old_pwd=$("#old_password").val();
        var new_pwd=$("#new_password").val();
        $("#sumbit_warning").html("");
        $("#sumbit_warning").html("");
        var tf=0;
        $.ajax({
            type: "post",
            url: "__APP__/home/student/checkpwd",
            async: true,
            data: {
                std_id: std_id,
                pwd:old_pwd
            },
            datatype: "json",
            success: function (data) {
                if(data.status==0)
                {
                    $.ajax({
                        type: "post",
                        url: "__APP__/home/student/update_pwd",
                        async: true,
                        data: {
                            std_id: std_id,
                            pwd:new_pwd,
                            old_pwd:old_pwd
                        },
                        datatype: "json",
                        success: function (data) {
                            var str="";
                            if(data.status==0)
                            {
                                $("#sumbit_warning").html("密码修改成功")
                            }
                            else
                            {
                                $("#sumbit_warning").html(data.info)
                                return false
                            }
                        },
                        error:function(data)
                        {
                            $("#sumbit_warning").html("网络异常，请刷新重试")
                            return false
                        }
                    });
                }
                else
                {
                    $("#sumbit_warning").html("原始密码有误，请重新输入")
                    return false;
                }
            },
            error:function(data)
            {
                $("#sumbit_warning").html("网络异常，请刷新重试")
                return false;
            }
        });
    });
</script>
<!-- start footer -->
{include file="public/footer"/}